package day26.a02test;


import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test {
    public static void main(String[] args) {
        //1.将一个集合中的偶数筛选出来，并打印
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        List<Integer> collect = list.stream().filter(s -> (Integer) s % 2 == 0).collect(Collectors.toList());
        System.out.println(collect);

        //2.
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1,"zhangsan,23","lisi,24", "wangwu,25");
        Map<String, Integer> map = list1.stream()
                .filter(s -> Integer.parseInt(s.split(",")[1]) >= 24)
                .collect(Collectors.toMap(
                        s -> s.split(",")[0],
                        s -> Integer.parseInt(s.split(",")[1])));
        System.out.println(map);

        //3.
        ArrayList<String> man = new ArrayList<>();
        ArrayList<String> woman = new ArrayList<>();
        Collections.addAll(man,"蔡坤坤,24" , "叶齁咸,23", "刘不甜,22", "吴签,24", "谷嘉,30", "肖梁梁,27");
        Collections.addAll(woman,"赵小颖,35" , "杨颖,36", "高元元,43", "张天天,31", "刘诗,35", "杨小幂,33");
        Stream<String> stream1 = man.stream()
                .filter(s -> s.split(",")[0].length() == 3)
                .limit(2);


        Stream<String> stream2 = woman.stream()
                .filter(s -> s.split(",")[0].startsWith("杨"))
                .skip(1);

        List<Actor> actors = Stream.concat(stream1, stream2)
                .map(s -> new Actor(s.split(",")[0], Integer.parseInt(s.split(",")[1])))
                .collect(Collectors.toList());
        System.out.println(actors);


    }
}
